<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

//跨域请求
$allow_origin = array(
    "http://localhost:8080",
    "http://localhost:9529"
);
//跨域访问的时候才会存在此字段
$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';  
if (in_array($origin, $allow_origin)) {
    header('Access-Control-Allow-Origin:' . $origin);
}
//header("Access-Control-Allow-Origin: http://localhost:8080");
header('Access-Control-Allow-Headers:token,content-type');
header('Access-Control-Allow-Credentials:true');

// Route::group('v1', function () {

// })->prefix("admin/")->allowCrossDomain([
//     'Access-Control-Allow-Origin'        => '*',
//     'Access-Control-Allow-Credentials'   => 'true',
//     'Access-Control-Allow-Headers'   => 'token,Content-Type',
// ]);
//无需登录就可访问的公共接口
Route::group(function () {
    Route::rule('login$', 'userLogin');
    //用户退出登录
    Route::rule('logout$', 'userLogout');
    
    //用户用手机号注册账户
    Route::rule('reg/phone$', 'phoneReg');
})->prefix('v1.common/');


